// 文章请求模块
import request from '@/utils/request'

// 请求文章数据
export const getArticleAPI = (params) => {
  return request({
    method: 'GET',
    url: '/v1_0/articles',
    params: params
  })
}
// 请求文章
export const getAticleByIdAPI = aticleId => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${aticleId}`
  })
}

// 添加文章收藏
export const addCollectAPI = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}

// 取消文章收藏
export const delCollectAPI = targetId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${targetId}`
  })
}

// 点赞文章
export const addLikeAPI = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target
    }
  })
}

// 取消文章点赞
export const delLikeAPI = targetId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${targetId}`
  })
}
